/**
 * Created by Wilson on 3/12/2015.
 */
(function () {
    angular.module('app')
        .controller('registerController', registerController);

    registerController.$inject = ['$scope', 'constant', 'userService'];
    function registerController($scope, constant, userService) {
        $scope.sex = null;

        $scope.selectMale = selectMale;

        $scope.selectFemale = selectFemale;

        $scope.registerUser = registerUser;

        $scope.user = {
            membermobile: '',
            memberPwd: '',
            levelId: constant.LV_CLIENT,
            detailSex: '',
            detailName: ''
        };

        function registerUser() {
            console.log($scope.user);
            var u = $scope.user;
            userService.register(u.membermobile, u.memberPwd, u.levelId, u.detailSex, u.detailName);
        }

        function selectMale() {
            $scope.sex = true;
            $scope.user.detailSex = constant.SEX_MALE;
        }

        function selectFemale() {
            $scope.sex = false;
            $scope.user.detailSex = constant.SEX_FEMALE;
        }

    }
})();